<!-- src/components/AboutPopup.vue -->
<template>
  <div v-if="isVisible" class="popup-overlay" @click="close">
    <div class="popup-content" @click.stop>
      <div class="popup-header">
        <span>{{ title }}</span>
        <button class="close-button" @click="close">&times;</button>
      </div>
      <div class="popup-body">
        <p>版本号: {{ version }}</p>
        <button class="update-button" @click="checkForUpdates">检查更新</button>
      </div>
    </div>
  </div>
</template>

<script setup>
import {ref} from "vue";

const props = defineProps({
  isVisible: Boolean,
  version: String,
  title: {
    type: String,
    default: "关于"
  }
});

const emit = defineEmits(['close', 'check-for-updates']);

const close = () => {
  emit('close');
};

const checkForUpdates = () => {
  emit('check-for-updates');
};
</script>

<style scoped>
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup-content {
  border-radius: 50px;
  width: 80%;
  max-width: 400px; /* 可选：限制最大宽度 */
  height: 300px;
  background-color: #fff8f8;
  box-shadow: #b1b1b1 3px 3px 3px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  box-sizing: border-box;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-header span {
  font-size: 18px;
  font-weight: bold;
  color: blue;
}

.close-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #333;
}

.popup-body {
  font-size: 16px;
  color: #555;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.update-button {
  width: 300px;
  border: none;
  height: 100px;
  border-radius: 30px;
  background-color: red;
  color: #ffcccc;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.update-button:hover {
  background-color: darkred;
}
</style>

